﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Practices.ServiceLocation;
using MODEL;
using ViewModel.AlertCreate;
using GalaSoft.MvvmLight.Messaging;
using GalaSoft.MvvmLight;
using Resource.AttachedProperty;

namespace msap.AlertCreate.AlertRecord
{
    /// <summary>
    /// Index.xaml 的交互逻辑
    /// </summary>
    public partial class IndexForm : Page
    {
        public IndexForm()
        {
            InitializeComponent();
            Messenger.Default.Register<ViewModelBase>(this,"AlertRecord_ShowDetail", true, ShowAlertRecordDetailWindow);
            Messenger.Default.Register<ViewModelBase>(this,"AlertRecord_ShowMessageReleaseForm", true, ShowMessageReleaseWindow);
        }

        public void ShowAlertRecordDetailWindow(ViewModelBase vm)
        {
            DetailForm form = new DetailForm();
            form.DataContext = vm;
            form.ShowDialog();
        }

        public void ShowMessageReleaseWindow(ViewModelBase vm)
        {
            MessageRelease.MessageRelease.IndexForm form = new MessageRelease.MessageRelease.IndexForm();
            form.DataContext = vm;
            UserControls.CustomizeDialog dialog = new UserControls.CustomizeDialog(form);
            dialog.ShowDialog();

            (this.DataContext as AlertRecordViewModel).RefreshData();
        }
    }
}
